import 'package:animal/utils/screen_util.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:getwidget/getwidget.dart';

import 'image_loading.dart';

///通用头像布局
class Header {
  static Widget defaultHead({
    String? imageUrl,
    BorderRadius? borderRadius,
    GFAvatarShape? shape,
    double? size,
    double? height,
    double? width,
    double? radius,
    Border? border,
  }) {
    return Container(
      decoration: BoxDecoration(borderRadius: borderRadius ?? BorderRadius.circular(ScreenUtil().L(radius ?? 10)), border: border),
      child: ClipRRect(
        borderRadius: borderRadius ?? BorderRadius.circular(ScreenUtil().L(radius ?? 10)),
        child: CachedNetworkImage(
          placeholder: (context, url) => const ImageLoadingWidget(),
          errorWidget: (context, url, error) => const Icon(Icons.error),
          fit: BoxFit.cover,
          imageUrl: imageUrl!=null &&imageUrl != ""?imageUrl:"https://cdn.pixabay.com/photo/2019/12/20/00/03/road-4707345_960_720.jpg",
          height: ScreenUtil().L(height ?? 60),
          width: ScreenUtil().L(width ?? 60),
        ),
      ),
    );
  }
}
